<template>
    <div>
        <h2>老师登录页面</h2>  
        <p>老师用户名：<input type="text" v-model="name"></p>
        <p>老师密码：<input type="password" v-model="password"></p> 
        <button @click="login()">登录</button> 
    </div>    
</template>

<script>
import axios from "axios"
export default {
    name:"login",
    data() {
        return {
            name:"",
            password:""
        }
    },
    methods:{
        login(){
            var data={
                "name":this.name,
                "password":this.password
            }
            axios({
                url:"http://127.0.0.1:8000/app03/login/",
                method:"get",
                params:data
            }).then(res=>{
                console.log(res.data)
                alert("登录成功")
                localStorage.setItem('id',res.data.data.id);
                this.$router.push({name:"fristpage"})
            })
        }
    }
}
</script>

<style>

</style>
